package com.qianfeng.smartplatform.dto;/*
 *@Description:
 *@author:赵健
 *@Date:zjzzz 2022/9/7 17:38
 */

import com.fasterxml.jackson.annotation.JsonInclude;
import com.qianfeng.smartplatform.constans.ResultCode;

@JsonInclude(JsonInclude.Include.NON_EMPTY)
public class R {
    private int code;
    private String msg;
    private Object data;

    public static R OK() {
        return OK(null);
    }

    public static R OK(Object data) {
        return getResult(ResultCode.SUCCESS, "成功", data);
    }

    public static R ERROR() {
        return ERROR(null);
    }

    public static R ERROR(Object data) {
        return getResult(ResultCode.FAIL, "失败", data);
    }


    public static R getResult(int code, String msg) {
        return getResult(code, msg, null);
    }

    public static R getResult(int code, String msg, Object data) {
        R r = new R();
        r.setCode(code);
        r.setMsg(msg);
        r.setData(data);
        return r;
    }


    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}
